<template>
  <div>
      <table border="1">
          <tr>
              <td>名称</td>
              <td>操作</td>
          </tr>
          <tr v-for="i in list">
              <td>{{i.name}}</td>
              <td> <button @click="putlist(i.id)">修改</button>  <button @click="dellist(i.id)">删除</button></td>
          </tr>
      </table>
  </div>
</template>

<script>
export default {
data(){
    return{
        list:[],
    }
},
methods:{
    //分类展示
    getlist(){
        this.$axios.get('cateM')
        .then(res=>{
            this.list = res.data.list
        })
    },
    // 分类删除
    dellist(id){
        this.$axios.delete('cateM?id='+id)
        .then(res=>{
            this.getlist()
            alert("删除成功")
        })
    },
    // 分类修改
    putlist(id){
        // path 跳转地址 query 传的值
        this.$router.push({path:'updatecate',query:{'id':id}})
    }
    
},
mounted(){
    this.getlist()
},
}
</script>

<style>

</style>